<?php 

class Scaffold extends Cloud {
	
	function __construct(){
		parent::__construct();
		$this->load_model('model');
		$this->load_helper('url');
	}
	
	function usage(){
		echo "the scaffold!";
		$this->index();
	}
	
	function index($table = null){
		
		dbg($this->cloud->url);
		$this->data['tables'] = $this->model->get_all_tables();
		if($table != null){
			$this->data['rows'] = $this->model->get_table_content($table);
			dbg($this->data['rows']);
		}
		$this->display_tables();
	}
	
	private function display_tables(){
		foreach($this->data['tables'] as $row){
			foreach($row as $table){
				echo "<a href='". url(true). 'scaffold/'.$table ."'>$table</a><br/>";
			}
		}
	}

}

?>